<?php


/**
* 订单列表管理模型
*/
class OrderListModel extends Model{
    public $table='order_list';
    
    /*添加订单
     * */
    public function addList($oid){
    	$GLModel=K('GoodsList');
		$GModel=K('Goods');
        foreach ($_SESSION['cart']['goods'] as $v) {
        	$data=array(
				'price'=>$v['price'],
				'num'=>$v['num'],
				'order_oid'=>$oid,
				'goods_list_glid'=>$v['glid'],
				'goods_gid'=>$v['id']
			);
			$this->add($data);
			//对应商品的库存减掉商品的数量
			$GLModel->dec('inventory',"glid={$v['glid']}",$v['num']);
			//商品库存减掉商品的数量
			$GModel->dec('store',"gid={$v['id']}",$v['num']);
        }
    }
}   
    
    
?>